home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / gnuplsrc.zip / WINEXTRA.C < prev   
C/C++ Source or Header  |  1993-03-21  |  5KB  |  156 lines

  1. #ifdef INCRCSDATA
  2. static char RCSid[]="$Id: winextra.c,v 1.2 1992/07/26 12:37:10 fearick Exp fearick $" ;
  3. #endif
  4.  
  5. /* winextra.c -- some functions that should have been in os/2 1.2,1.3 */
  6. /*
  7.     Copyright (c) 1992, Roger Fearick.
  8.     All rights reserved
  9.      
  10.     THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT WARRANTIES OF ANY KIND. 
  11.    
  12.     Permission is hereby granted for personal, non-commercial use of this 
  13.     software.You are granted the right to use, modify, and redistribute 
  14.     it for for non-commercial purposes, provided that all copyright 
  15.     notices remain intact and all changes are clearly documented.      
  16.     THE AUTHOR MAKES NO WARRANTY OF ANY KIND WITH RESPECT TO THIS PRODUCT 
  17.     AND EXPLICITLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY 
  18.     OR FITNESS FOR ANY PARTICULAR PURPOSE.                               
  19. */
  20.  
  21. /* Update Log
  22. **
  23.  * $Log: winextra.c,v $
  24.  * Revision 1.2  1992/07/26  12:37:10  fearick
  25.  * Initial 32-bit version
  26.  *
  27.  * Revision 1.1  1992/07/25  15:44:54  fearick
  28.  * Initial revision
  29.  *
  30.  *
  31. */ 
  32.  
  33. #define INCL_PM
  34. #define INCL_WIN
  35. #include <os2.h>
  36. #include <math.h>
  37. #include <stdlib.h>
  38. #include <string.h>
  39.  
  40. extern HWND hwndFrame ; /* sometime, change so this is arg, or other, ...*/
  41.  
  42. void    ChangeCheck( HWND, USHORT, USHORT ) ;
  43. void    ChangeGrey( HWND, USHORT, USHORT ) ;
  44. void    WinSetDlgItemLong( HWND, USHORT, ULONG, BOOL ) ;
  45. void    WinSetDlgItemFloat( HWND, USHORT, float ) ;
  46. void    WinSetDlgItemFloatF( HWND, USHORT, int, float ) ;
  47. void    WinQueryDlgItemFloat( HWND, USHORT, float* ) ;
  48.  
  49.  
  50. void ChangeCheck( HWND hWnd , USHORT wItem1 , USHORT wItem2 )
  51. /*
  52. **  Utility function:
  53. **
  54. **  move check mark from menu item 1 to item 2
  55. */
  56.     {
  57.     HWND hMenu ;
  58.  
  59.     hMenu = WinWindowFromID( hwndFrame, FID_MENU ) ;            
  60.     if( wItem1 != 0 )
  61.         WinSendMsg( hMenu,
  62.                     MM_SETITEMATTR,
  63.                     MPFROM2SHORT( wItem1, TRUE ),
  64.                     MPFROM2SHORT( MIA_CHECKED, 0 ) ) ;
  65.     if( wItem2 != 0 )
  66.         WinSendMsg( hMenu,
  67.                     MM_SETITEMATTR,
  68.                     MPFROM2SHORT( wItem2, TRUE ),
  69.                     MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED ) ) ;
  70.     }       
  71.  
  72. void ChangeGrey( HWND hwnd, USHORT iItem, USHORT iState )
  73. /*
  74. **  Change greyed state of menu item iMenu
  75. **  State may be 0 or MIA_DISABLED
  76. */
  77.     {
  78.     HWND hMenu ;
  79.  
  80.     hMenu = WinWindowFromID( hwndFrame, FID_MENU ) ;            
  81.     WinSendMsg( hMenu, 
  82.                 MM_SETITEMATTR,
  83.                 MPFROM2SHORT( iItem, TRUE ),
  84.                 MPFROM2SHORT( MIA_DISABLED, iState ) ) ;
  85.     }
  86.  
  87. void WinSetDlgItemLong( HWND hwnd, USHORT usID, ULONG ulValue, BOOL bSign )
  88. /*
  89. ** A function microsoft forgot ( in v1.1) , see WinSet...Short
  90. */
  91.     {
  92.     char achBuffer [ 34 ] ; // default string field size ...
  93.     
  94.     if( bSign ) sprintf(achBuffer, "%ld", ulValue );
  95.     else       sprintf(achBuffer, "%uld", ulValue );
  96.     WinSetDlgItemText( hwnd, usID, achBuffer ) ;
  97.     }
  98.  
  99.  
  100. void WinSetDlgItemFloatF( HWND hwnd, USHORT usID, int nDec, float flValue )
  101. /*
  102. ** A function microsoft forgot ( in v1.1) , see WinSet...Short
  103. */
  104.     {
  105.     char achBuffer [ 34 ], *szCvt ; // default string field size ...
  106.     int  iDec ;
  107.     int  iSign ;
  108. #ifdef NEVER    
  109.     szCvt = fcvt( (double)flValue, nDec,  &iDec, &iSign ) ;
  110.     achBuffer[0] = '\0' ;
  111.     if( iSign != 0 ) strcat( achBuffer, "-" ) ;
  112.     if( iDec > 0 )
  113.         strncat( achBuffer, szCvt, iDec ) ;
  114.     else 
  115.         strcat( achBuffer, "0" ) ;
  116.     strcat( achBuffer, "." ) ;
  117.     if( iDec < 0 )
  118.         for( iSign = -iDec ; iSign > 0 ; iSign-- ) strcat( achBuffer, "0" ) ;
  119.     strcat( achBuffer, szCvt+(iDec>0?iDec:0) ) ;
  120. #endif
  121.     char fmt[10] ;
  122.     sprintf( fmt, "%%12.%df", nDec ) ;
  123.     sprintf( achBuffer, fmt, flValue ) ;
  124.     WinSetDlgItemText( hwnd, usID, achBuffer ) ;
  125.     }
  126.  
  127. void WinSetDlgItemFloat( HWND hwnd, USHORT usID, float flValue )
  128. /*
  129. ** A function microsoft forgot ( in v1.1) , see WinSet...Short
  130. */
  131.     {
  132.     char achBuffer [ 34 ] ; // default string field size ...
  133. #ifdef NEVER    
  134.     gcvt( (double)flValue, 4, achBuffer ) ;
  135. #endif
  136.     char fmt[10] ;
  137.     sprintf( fmt, "%%12.%df", 4 ) ;
  138.     sprintf( achBuffer, fmt, flValue ) ;
  139.     WinSetDlgItemText( hwnd, usID, achBuffer ) ;
  140.     WinSetDlgItemText( hwnd, usID, achBuffer ) ;
  141.     }
  142.  
  143. void WinQueryDlgItemFloat( HWND hwnd, USHORT usID, float *pflValue )
  144. /*
  145. ** A function microsoft forgot ( in v1.1) , see WinQ...Short
  146. */
  147.     {
  148.     char achBuffer [ 34 ] ; // default string field size ...
  149.     ULONG ulTemp ;
  150.     
  151.     WinQueryDlgItemText( hwnd, usID, 34, achBuffer ) ;
  152.     *pflValue = (float) atof( achBuffer ) ;
  153.     }
  154.  
  155.  
  156.